package com.dawn.module.cms.api.doctor;

import com.dawn.framework.common.pojo.PageParam;
import com.dawn.framework.common.util.object.BeanUtils;
import com.dawn.module.cms.api.doctor.dto.CmsDoctorRespDTO;
import com.dawn.module.cms.controller.admin.doctor.vo.DoctorPageReqVO;
import com.dawn.module.cms.controller.admin.doctor.vo.DoctorRespVO;
import com.dawn.module.cms.dal.dataobject.doctor.DoctorDO;
import com.dawn.module.cms.service.doctor.DoctorService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;



/**
 * 医生的 API 实现类
 *
 * @author dawn
 */
@Service
@Validated
public class CmsDoctorApiImpl implements CmsDoctorApi {


    @Resource
    private DoctorService doctorService;

    @Override
    public CmsDoctorRespDTO getDoctor(Long id) {
        DoctorDO doctor = doctorService.getDoctor(id);
        return BeanUtils.toBean(doctor, CmsDoctorRespDTO.class);
    }

    @Override
    public List<CmsDoctorRespDTO> getList() {
        DoctorPageReqVO pageReqVO = new DoctorPageReqVO();
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        List<DoctorRespVO> list = doctorService.getDoctorPage(pageReqVO).getList();
        return BeanUtils.toBean(list, CmsDoctorRespDTO.class);
    }

    @Override
    public List<CmsDoctorRespDTO> getListByName(String name) {
        DoctorPageReqVO pageReqVO = new DoctorPageReqVO();
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        pageReqVO.setName(name);
        List<DoctorRespVO> list = doctorService.getDoctorPage(pageReqVO).getList();
        return BeanUtils.toBean(list, CmsDoctorRespDTO.class);
    }
}
